package com.deer.wms.base.system.dao.bill;


import com.deer.wms.base.system.model.bill.*;
import com.deer.wms.base.system.model.task.TaskInfoDto;
import com.deer.wms.base.system.model.zh.WorkTasks;
import com.deer.wms.common.core.commonMapper.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;

import java.util.List;

/**
 * 入库单 数据层
 * 
 * @author cai
 * @date 2019-07-15
 */
public interface BillOutMasterMapper extends Mapper<BillOutMaster>
{

	/**
	 * 根据billId查询出库单信息
	 */
	public BillOutMasterDto findBillOutMasterDtoByBillId(Integer billId);

	/**
	 *
	 * @author 李帅辰
	 * @date 17:50 2020/10/30
	 * @params BillNo
	 * @return com.deer.wms.base.system.model.bill.BillOutMasterDto
	 **/
	public BillOutMasterDto findBillOutMasterDtoByBillNo(String billNo);

	/**
	 * 删除入库单
	 *
	 * @param billId 入库单ID
	 * @return 结果
	 */
	public int deleteBillOutMasterById(Integer billId);

	/**
	 * 批量删除入库单
	 *
	 * @param billIds 需要删除的数据ID
	 * @return 结果
	 */
	public int deleteBillOutMasterByIds(String[] billIds);



	/**
	 * 修改BillOutMaster信息
	 *
	 * @param billOutMaster
	 */
	public int updateBillOutMaster(BillOutMaster billOutMaster);




	/**
	 * 出库单审核通过
	 * @param billId
	 * @return
	 */
	int auditFinish(Integer billId);

	public BillOutMaster selectBillOutMasterById(Integer billId);


	/**
	 * 保存BillOutMaster  出库单
	 *
	 * @param billOutMaster
	 */
	public int saveBillOutMaster(BillOutMaster billOutMaster);

	/**
	 *
	 * 查询出库单
	 *
	 * @return
	 */
	public List<BillOutMasterDto> selectBillOutMasterList(BillOutMasterDto billOutMasterDto);

	/**
	 * 获取出库单据的总数
	 */
	int BillOutMasterCount();

	/**
	 * 获取状态下的总数
	 * @return
	 */
	int BillOutMasterCountByType();

	/**
	 * 折线图 每天的总数
	 * @return
	 */
	List<Integer> getAllWeek();


	BillOutMaster selectBillOutMasterByBillOutDetailId(Integer billOutDetailId);

	List<BillOutMasterDto> findList(BillOutMasterCriteria criteria);

	List<BillOutMasterDto> findExport(BillOutMasterCriteria criteria);
	/*出库流水*/
    List<BillOutDetailDeviceDto> selectDetailStreamList(BillOutDetailDeviceDto billOutDetailDeviceDto);
	/*根据billId查询出库计划*/
    List<BillOutPlanDto> findBillOutPlanByBillId(Integer billId);
	/*根据出库计划id查询出库明细*/
    List<BillOutDetailDto> findBillOutDetailByPlanId(Integer planId);
	/*根据出库明细id查询机台列表明细*/
    List<BillOutDetailDto> findDeviceListByDetailId(BillOutDetail billOutDetail);
	/*出库计划查询*/
	List<BillOutPlanDto> selectBillOutPlanList(BillOutPlanDto billOutPlanDto);
	/*待出库单列表*/
    List<BillOutMasterDto> selectWaitBillOutMasterList(BillOutMasterDto billOutMasterDto);
	/*查询机台列表*/
	List<DeviceManager> findDeviceList(DeviceManager deviceManager);
	/*根据出库单id查sap物料明细*/
	List<MATNRvo> findMATNRByBillId(Integer billId);
	/*新建出库计划*/
	void insertBillOutPlan(BillOutPlan billOutPlan);
	/*新建计划单明细*/
	void insertBillOutDetail(BillOutDetail billOutDetail);
	/*新建机台明细*/
	void insertBillOutDetailDevice(BillOutDetailDevice billOutDetailDevice);
	/*根据planId查询出库计划*/
    BillOutPlanDto findBillOutPlanByPlanId(Integer planId);
	/*明细添加任务id*/
    void saveTaskId(BillInDetail billInDetail);
	/*根据出库计划id查询未出库明细*/
    List<BillOutDetailDto> getBillOutDetailByPlanId(Integer billOutPlanId);
	/*根据sapId修改对应入库单的sapNo*/
    void updateSapNoBySapId(BillOutSap billOutSap);
    /*改明细状态*/
    void updateBillOutDetailStateById(Integer billOutDetailId);
	/*查询未完成明细数量*/
    int findBillOutOver(Integer planId);
	/*改变出库单状态*/
	void updateBillOutPlanState2(Integer billOutPlanId);
	void updateBillOutPlanState3(Integer billOutPlanId);
	/*根据计划id和物料名称查sap明细id*/
    int findSapIdByPlanId(WorkTasks workTasks);
	/*修改重量*/
	void updateSapWright(BillOutSapDetail billOutSapDetail);
	/*查对比重量*/
	BillOutSapDetail findDetailWeight(Integer sapId);
	/*更改状态*/
	void updateSapDetailState(BillOutSapDetail detailWeight);
    /*SAP明细完成状态*/
    int sumPlan(Integer billOutPlanId);
	/*查询SAPid*/
	int findSapIdByDetailId(Integer sapId);
	/*计划单完成*/
	void updatePlan(Integer id);
	/*查出库类型*/
	Integer findBillOutType(Integer id);
	/*出库单强制完成*/
    void planOver(Integer billOutPlanId);
	/*出库单明细强制完成*/
	void planDetailOver(Integer billOutPlanId);
	/*出库流水*/
    BillOutDetailDeviceDto getDetailSum(BillOutDetailDeviceDto detailAll);
}



















